// FunkyDog MailBundle - tags and keywords for Apple Mail 3.0
//    Copyright (C) 2008 saptarshi guha saptarshi.guha@gmail.com
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.


#import "SGTagView.h"
#import "FunkyDog.h"



@implementation SGTagView

- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
		backgroundImage=[[NSImage alloc] initWithSize:[self bounds].size];
		[self drawBackgroundImage];
	}
    return self;
}
-(void)drawBackgroundImage{
	NSGradient* aGradient = [[NSGradient alloc]	initWithStartingColor:[NSColor colorWithCalibratedWhite:0.85 alpha:1.0]
														  endingColor:[NSColor colorWithCalibratedWhite:0.7 alpha:1.0]];
	
	[backgroundImage lockFocus];
	[aGradient drawInRect:[self bounds] angle:270];
	[backgroundImage unlockFocus];	
	[self setBackgroundImage:backgroundImage];
	[aGradient release];
}
- (void)drawRect:(NSRect)rect {
	[self drawBackgroundImage];
	[super drawRect:rect];

}

- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize{
	[super resizeWithOldSuperviewSize:oldBoundsSize];
	[self setNeedsDisplay:YES];
}
- (void)viewDidEndLiveResize{
	[super viewDidEndLiveResize];
	[self setNeedsDisplay:YES];
}
@end
//
//-(NSView*)findSubviewOfClass:(Class)c inheir:(NSArray*)heirs{
//	NSView *ret;
//	for(NSView *vi in heirs){	
//		if ( [vi isKindOfClass:c]) {ret=vi; break;}
//		else{
//			if ( [[vi subviews] count] ==0) ret= nil; else {
//				ret= [self findSubviewOfClass:c inheir:[vi subviews]];
//				if (ret!=nil) break;
//			}
//		}
//	}
//	return ret;
//}
